﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="OneMG.Phoenix.AdminSite.Views.AdminUser.Index" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    管理用户
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadScripts" runat="server">
  <script type="text/javascript" src="/Scripts/m-former.js"></script>  
   <script type="text/javascript" src="/Scripts/m-lhgdialog/m-lhgdialog.js"></script>    
  
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <div class="path">
        <a href="/Views/AdminUser/index.aspx"><strong>用户管理</strong></a>
    </div>
    <div class="pd10">
        <div class="mb10 aL">
            <a href="javascript:;" title="新增" class="a-btn1" onclick="OpenPop('/Views/AdminUser/Edit.aspx', '新增商品类目',500,450)">新增</a>
        </div>
        <span id="Grid">
           <table class="tb-list hover">
    <tr>
        <th>
            用户ID
        </th>
        <th>
            用户名称
        </th>
        <th>
            用户邮箱
        </th>
        <th>
            创建时间
        </th>
        <th>
            最后登录
        </th>
        <th width="20%">
            操作
        </th>
    </tr>
   <% foreach (OneMG.Phoenix.Service.Model.AdminUserModel item in listModle) %>
    <%{%>
    <tr>
        <td>
           <%=item.UserName %>
        </td>
        <td>
         <%=item.TrueName %>
        </td>
        <td>
         <%=item.EMail%>
        </td>
        <td>
           <%=item.CreateTime %>
        </td>
        <td>
           <%=item.LastLoginTime%>
        </td>
        <td>
            <a href="javascript:void(showEdit('<%=item.UserID %>'))">编辑</a> 
            <a href="javascript:void(showRights('<%=item.UserID %>'))">功能权限</a> 
            <a href="javascript:;" onclick="DeleteCategory('<%=item.UserID %>')">删除</a>
            <a href="javascript:;" onclick="DeleteCategory('<%=item.UserID %>')">禁用</a>

        </td>
    </tr>
<%}%>
</table>
        </span>
            <!-- 分页插件  -->
                <!-- 分页插件  -->
        <div id="pager" class="aR mt10">
            <webdiyer:AspNetPager ID="AspNetPager1" runat="server" 
                onpagechanged="AspNetPager1_PageChanged" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" UrlPaging="True">
            </webdiyer:AspNetPager>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Scripts" runat="server">
<script type="text/javascript" src="/Scripts/library/m-pagination.js"></script>    
    <script type="text/javascript">
        (function() {
            pagerInit();
        })(jQuery);

        // 初始化分页插件
        function pagerInit(recordCount) {
            // 该分页为每次查询的ajax调用后获得的记数最大数，放在Grid.ascx
            var recordCount = parseInt($("#__recordCount__").text());

            $('#pager').pagination(recordCount, {
                fCallBack: pagerCallBack, // 回调方法
                nPageSize: 20, 			// 显示分页项数
                nDisplayItem: 5, 		// 一个分页显示的数据量
                nStartEndItem: 2, 		// 特长分页首尾显示分页项数
                nPageIndex: 0
            });

            // 分页回调
            function pagerCallBack(pageIndex, jq) {
                search(pageIndex);
            };
        };

        // 搜索
        function search(pageIndex) {
            var pIndex = 0;
            if (pageIndex !== undefined) {
                pIndex = pageIndex;
            }

            $.ajax({
                url: "/Views/Category/Index.aspx?pageIndex=" + pIndex,
                data: { "pid": $("#pid").val() },
                type: 'POST',
                success: function(data) {
                    // 填充数据

                    // 设置表格样式(调用全局方法)
                    TableHover();

                    // 当重新搜索时，重置分页
                    if (pIndex === 0) {
                        pagerInit();
                    }
                },
                error: function(XmlHttpRequest, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        };

        // 刷新列表
        function refresh() {
            var pageIndex = parseInt($("div.pagination>span.page").attr("title"));
            search(pageIndex - 1);
        };

        // 删除类目
        function DeleteCategory(categoryID) {
            if (confirm("确认删除吗?") == false) {
                return;
            }

            $.ajax({
                url: "/Views/Category/Delete.ashx",
                data: { "categoryID": categoryID },
                type: "POST",
                success: function(data, textStatus) {
                    if (data.status === "warning" || data.status === "error") {
                        alert(data.msg);
                        return false;
                    }
                    // 刷新列表
                    refresh();
                },
                error: function(XmlHttpRequest, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        };

        // 显示编辑
        function showEdit(userid) {
            OpenPop('/Views/AdminUser/edit.aspx?userid=' + userid, "编辑用户信息", 500, 450);
        };

        //功能权限
        function showRights(userid) {
            OpenPop('/Views/Passport/RightsAndType.aspx?userid=' + userid, "编辑权限", 500, 650);
        };

        //打开弹窗
        function OpenPop(url, titleName, width, height) {
            width = width || 800;
            height = height || 500;
            window.top.winObj = window;
            window.top.oDG = new $.dialog({ id: 'esDialog', title: titleName, page: url, width: width, height: height, btnBar: false, lockScroll: true });
            window.top.oDG.ShowDialog();
        }
        
</script> 
</asp:Content>
